﻿#pragma once

#include <QObject>
#include<qlist.h>
#include"Song.h"
#include<qmutex.h>
#include<qmetatype.h>
class SongList  : public QObject
{
	Q_OBJECT
private:
	
	QList<Song> m_songList;

	QMutex m_mutex;

public:
signals:
	void SongAppended(const Song s);
	void SongAppended(const QList<Song> s_list);

public:
	//单例
	//static SongList& getInstance();

	void appendSafe(const Song& s);
	void appendSafe(const QList<Song>& s_list);
	void remove(int index);
	/*QList<Song>& getSongList();*/
	//QList<Song>& getOnlineList();
	int size();

	Song& operator[](int index);
	
	QUrl getSongUrl(int index);
	SongList(QObject* parent = nullptr);
	//SongList(const SongList&) = delete;
	//SongList operator=(const SongList&) = delete;
	~SongList();
};

Q_DECLARE_METATYPE(QList<Song>)